<template>
  <div class="app-container">
    <!-- 订单列表 -->
    <div>
<!--      <div style="height: 30px;display: flex;align-items: center;justify-content: center;width: 180px;">-->
<!--        <span style="color: grey">视频状态：</span>-->
<!--        <el-switch-->
<!--          style=""-->
<!--          v-model="switchValue"-->
<!--          active-color="#13ce66"-->
<!--          inactive-color="#ff4949"-->
<!--          active-text="开"-->
<!--          @change="setVideoStatus"-->
<!--          inactive-text="关">-->
<!--        </el-switch>-->
<!--      </div>-->
        <div style="display: flex;flex-wrap: nowrap;">
          <div>
            <el-form>
              <!--<el-row class="rowFormItem">
                <el-col :span="3" style="margin-right: 10px;">
                </el-col>
                <el-col :span="3" style="margin-right: 10px;">

                </el-col>
                <el-col :span="3" style="margin-right: 10px;">

                </el-col>
                <el-col :span="3" style="margin-right: 10px;">

                </el-col>
                <el-col :span="3" style="margin-right: 10px;">

                </el-col>
                <el-col :span="3" style="margin-right: 10px;">

                </el-col>
                <el-col :span="4">
                  <el-form-item style="text-align: left;width: 300px;">

                  </el-form-item>
                </el-col>
              </el-row>-->
              <el-row class="rowFormItem" style="padding: 10px 0">
                <el-input style="width: 200px" v-model="form.keyword" placeholder="请输入关键词" />

                <el-select style="margin-left: 15px" v-model="form.study_type" placeholder="请选择服务形式">
                  <el-option v-for="item in studyWays" :key="item.id" :label="item.label" :value="item.id" />
                </el-select>
<!--                <el-select style="margin-left: 15px" v-model="form.teacher_id" placeholder="请选择律师">-->
<!--                  <el-option v-for="item in teacherList" :key="item.id" :label="item.label" :value="item.id" />-->
<!--                </el-select>-->
                <el-select style="margin-left: 15px" v-model="form.status" placeholder="请选择状态">
                  <el-option v-for="item in statusList" :key="item.id" :label="item.label" :value="item.id" />
                </el-select>
<!--                <el-select style="margin-left: 15px" v-model="form.is_featured" placeholder="请选择是否精选">-->
<!--                  <el-option v-for="item in selectedList" :key="item.id" :label="item.label" :value="item.id" />-->
<!--                </el-select>-->
<!--                <el-select style="margin-left: 15px" v-model="form.need_check_in" placeholder="请选择是否需要签到">-->
<!--                  <el-option v-for="item in signList" :key="item.id" :label="item.label" :value="item.id" />-->
<!--                </el-select>-->
                <el-button style="margin-left: 15px" type="primary" size="large" @click="handleSubmit()">检索</el-button>
                <el-button type="warning" size="large" style="margin-left: 8px;margin-right: 8px;" @click="handleReset()">重置</el-button>
<!--                <router-link style="margin-left: 8px;margin-right: 20px;" to="/courseManage/courseList/addCourse">-->
<!--                  <el-button style="margin-top: 12px" type="success" size="large">新建律师服务</el-button>-->
<!--                </router-link>-->
                <!--<el-button style="margin-top: 10px" :type="videoStatus==1?'danger':'success'" size="large" @click="setVideoStatus()">{{videoStatus==1?'下架视频':'上架视频'}}</el-button>-->
              </el-row>
            </el-form>
          </div>

        </div>

        <div class="tableClass">
          <el-table :data="formdata" v-loading="loading" :header-cell-style="{background:'#eef1f6',color:'#606266'}"
            border style="width: 100%;">
            <el-table-column align="center" prop="id" label="序号" />
            <el-table-column align="center" prop="photo_url" label="用户头像">
              <template slot-scope="scope">
                <el-button type="text" size="medium">
                  <img style="width: 50%;" :src="scope.row.user_info.photo_url" />
                </el-button>
              </template>
            </el-table-column>
            <el-table-column align="center" prop="user_info.nickname" label="昵称" />
            <el-table-column align="center" prop="score" label="健康程度" />
            <el-table-column align="center" prop="img_url" label="舌苔照">
              <template slot-scope="scope">
                <el-button type="text" size="medium">
                  <el-link :href="scope.row.img_url" target="_blank"><img style="width: 50%;" :src="scope.row.img_url" /></el-link>
                </el-button>
              </template>
            </el-table-column>
            <el-table-column align="center" prop="typeName" label="身体体质" />
            <el-table-column align="center" prop="shemianName" label="舌色" />
            <el-table-column align="center" prop="shemianDesc" min-width="300px" label="舌色描述" />
            <el-table-column align="center" prop="shexinName" label="舌型" />
            <el-table-column align="center" prop="shexinDesc" min-width="300px" label="舌型描述" />
            <el-table-column align="center" prop="taiseName" label="苔色" />
            <el-table-column align="center" prop="taiseDesc" min-width="300px" label="苔色描述" />
            <el-table-column align="center" prop="taizhiName" label="苔质" />
            <el-table-column align="center" prop="taizhiDesc" min-width="200px" label="苔质描述" />
            <el-table-column align="center" prop="created_at" min-width="160px" label="创建时间" />
          </el-table>
          <br>
          <!-- 分页 -->
          <div style="text-align: center;">
            <el-pagination background layout="prev, pager, next" @current-change="pageChange" :current-page="startpage" :page-size="pageSize"
              :total="totalusers" />
          </div>
        </div>
    </div>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        form: {
          keyword: "",
          study_type: "",
          teacher_id: "",
          is_featured: "",
          need_check_in: "",
          status: "",
        },
        loading: false, //加载中
        formdata: [],
        type_info:[],
        studyWays: [
          {
            "id":"online",
            "label":"线上"
          },
          {
            "id":"come",
            "label":"线下"
          }
        ],
        statusList: [{
            "id": 0,
            "label": "下架"
          },
          {
            "id": 1,
            "label": "上架"
          }
        ],
        selectedList: [{
            "id": 0,
            "label": "非精选"
          },
          {
            "id": 1,
            "label": "精选"
          }
        ],
        signList: [{
            "id": 0,
            "label": "不签到"
          },
          {
            "id": 1,
            "label": "签到"
          }
        ],
        teacherList: [],
        totalusers: 0, //总页数
        pageSize: 10, //每页几行
        startpage: 1, //起始页
        videoStatus: '',
        switchValue: ''
      }
    },
    created() {

      if(window.sessionStorage.getItem("coursePage")){
        this.startpage = parseInt(window.sessionStorage.getItem("coursePage"))
      }
    },
    mounted() {
      this.getCourseList()
      this.getTeacherList()
      this.getVideoStatus()
    },

    watch: {
      /*videoValue(val) {
        if(val==1){
          this.switchValue = true
        } else{
          this.switchValue = false
        }
      }*/
    },
    methods: {
      onCopy(e){
        this.$message({
          type:'success',
          message:'复制成功'
        })
      },
      onError(erro){
        this.$message({
          type:'error',
          message:'复制失败'
        })
      },
      //获取导师列表
      getTeacherList() {
        this.teacherList = []
        let params = {
          "page": 1,
          "limit": 100000
        }
        this.$api.getTeacherList(params).then(res => {
          res.data.data.forEach(item => {
            let option = {
              "id": item.id,
              "label": item.name
            }
            this.teacherList.push(option)
          })
        })
      },
      //搜索
      handleSubmit() {
        this.getCourseList()
      },
      //重置
      handleReset() {
        this.form.keyword= "",
        this.form.study_type= "",
        this.form.teacher_id="",
        this.form.is_featured= "",
        this.form.need_check_in="",
        this.form.status= ""

      },
      //获取分页列表
      getCourseList() {
        this.loading = true
        let params = {
          "page": this.startpage,
          "limit": this.pageSize,
          // "keyword": this.form.keyword,
          // "study_type": this.form.study_type,
          // "teacher_id": this.form.teacher_id,
          // "is_featured": this.form.is_featured,
          // "need_check_in": this.form.need_check_in,
          // "status": this.form.status,
        }
        //调用后台提供的接口方法
        this.$api.getAiRecords(params).then((res) => {
          if (res.data.level == "success") {
            this.formdata = res.data.data
            // this.type_info = res.data.data.type_info
            this.totalusers = res.data.page_info.total
            this.loading = false
          }else {
            this.$message.error(res.data.message)
            this.loading = false
          }
        })

      },
      //分页 pageChange当前页发生改变触发函数
      async pageChange(page) {
        this.startpage = page
         window.sessionStorage.setItem("coursePage",this.startpage)
        //调用获取列表的方法
        this.loading = true
        this.getCourseList()
      },

      async getVideoStatus() {
        let res = await this.$api.getVideoStatus()
        this.videoStatus = res.data.data.status
        if(this.videoStatus==1){
          this.switchValue = true
        } else{
          this.switchValue = false
        }
      },

      async setVideoStatus() {
        let status = this.videoStatus==1?0:1
        let res = await this.$api.setVideoStatus({status: status})
        if(res.data.level=="success"){
          this.$message.success(res.data.message)
          this.getVideoStatus()
        } else{
          this.$message.error(res.data.message)
        }
      }

    }
  }
</script>
<style scoped="scoped">
  /deep/.el-card__header {
    background-color: #409EFF;
    color: whitesmoke;
  }

  /deep/.el-dialog {
    width: 40%;
    margin-top: 5vh !important;
    margin-bottom: 10vh;
  }

  .msgDiv {
    width: 80%;
    margin: auto;
    text-align: center;
  }

  /* model */
  .businessDialog /deep/.el-dialog__title {
    font-size: 26px;
    text-align: center;
    font-weight: bold;
  }

  .businessDialog /deep/.el-dialog__body {
    padding: 30px 50px;
    background-color: #dddddd57;
  }

  .businessDialog /deep/.el-dialog {
    margin-top: 10vh !important;
    width: 33%;
  }

  .businessCss .msgDiv {
    width: 80%;
    margin: auto;
    text-align: center;
  }

  .businessCss /deep/.el-form-item__label {
    font-size: 20px !important;
    text-align: right !important;
  }

  .businessCss /deep/.el-form-item__content {
    font-size: 20px !important;
  }

  /* 任务详细CSS */
  .taskWarp /deep/.el-form-item {
    margin-left: 15px;
  }

  .taskWarpTitle /deep/.el-dialog__title {
    font-size: 22px;
  }

  .taskWarp /deep/.el-form-item__label {
    font-size: 18px;
  }

  .taskCss {
    margin-left: 30px;
    margin-right: 30px;
    font-size: 16px;
    background-color: #dddddd57;
    text-align: left;
    padding: 10px 30px 10px 30px;
    margin-bottom: 10px;
    border-radius: 10px;
  }

  .taskCss span.title {
    font-weight: bold;
  }

  .taskCss span.name {
    color: #e21515eb;
  }

  .taskName {
    font-size: 22px;
    color: #e21515eb;
    background-color: #dddddd57;
    display: inline-block;
    padding: 5px 12px 5px 12px;
    font-weight: bold;
    font-family: serif;
    border-radius: 5px;
  }

  .indentLeft {
    margin-left: 26px;
  }

  .requiredCSS {
    margin-left: 30px;
    margin-right: 30px;
    background-color: #dddddd57;
    border-radius: 10px;
    padding: 10px 30px 10px 30px;
  }

  /deep/.edui-editor-imagescale {
    top: 130px !important;
  }

  /* 图片上传css */
  .avatar-uploader /deep/.el-upload {
    border: 1px dashed #807979;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }

  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }

  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 100px;
    height: 100px;
    line-height: 100px;
    text-align: center;
  }

  .avatar {
    width: 100px;
    height: 100px;
    display: block;
  }

  /* model */
  .businessDialog /deep/.el-dialog__title {
    font-size: 26px;
    text-align: center;
    font-weight: bold;
  }

  .businessDialog /deep/.el-dialog__body {
    padding: 30px 50px;
    background-color: #dddddd57;
  }

  .businessDialog /deep/.el-dialog {
    margin-top: 10vh !important;
    width: 33%;
  }

  .businessCss .msgDiv {
    width: 80%;
    margin: auto;
    text-align: center;
  }

  /deep/.el-form-item__label {
    padding: 0px 12px 0px 20px;
  }

  .businessCss /deep/.el-form-item__label {
    font-size: 20px !important;
    text-align: right !important;
  }

  .businessCss /deep/.el-form-item__content {
    font-size: 20px !important;
  }

  /* 选择框*/
  .checkboxLeft {
    text-align: left;
    margin-bottom: 15px;
  }

  /deep/.el-checkbox__inner {
    /* width: 18px;
    height: 18px; */
  }

  /deep/.el-checkbox__label {
    font-size: 16px;
  }

  .checkSpan {
    width: 80px;
    line-height: 40px;
    font-size: 16px;
    text-align: right;
    margin-right: 10px;
  }

  /deep/ .el-switch__label.is-active{

  }

</style>
